#!/bin/bash





echo '------------remove the java old version----------------'

yum -y remove java-1.7.0-openjdk*  
yum -y remove java-1.8.0-openjdk*

echo '----------get the java tar---------------'


mkdir /usr/java
mkdir /backup
cd  /usr/java
curl -O https://repo.huaweicloud.com/java/jdk/8u151-b12/jdk-8u151-linux-x64.tar.gz
tar zxvf jdk-8u151-linux-x64.tar.gz
mv jdk-8u151-linux-x64.tar.gz /backup

echo '-------------------update the java home--------------------------'

touch /etc/profile.d/jdk1.8.0_151.sh
echo 'export JAVA_HOME=/usr/java/jdk1.8.0_151' >> /etc/profile.d/jdk1.8.0_151.sh
echo 'export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar' >>/etc/profile.d/jdk1.8.0_151.sh
echo 'export PATH=$PATH:$JAVA_HOME/bin' >> /etc/profile.d/jdk1.8.0_151.sh
chmod +x /etc/profile.d/jdk1.8.0_151.sh
source /etc/profile.d/jdk1.8.0_151.sh
java -version

echo '-------------------install maven--------------------'
mkdir -p /usr/maven
cd /usr/maven
curl -O https://repo.huaweicloud.com/apache/maven/maven-3/3.5.3/binaries/apache-maven-3.5.3-bin.tar.gz
tar zxvf apache-maven-3.5.3-bin.tar.gz
touch /etc/profile.d/maven3_53.sh
echo 'export MAVEN_HOME=/usr/local/apache-maven-3.5.3' >> /etc/profile.d/maven3_53.sh
echo 'export PATH=$PATH:$MAVEN_HOME/bin' >> /etc/profile.d/maven3_53.sh
chmod +x /etc/profile.d/maven3_53.sh
source /etc/profile.d/maven3_53.sh



echo '---------------valid the maven --------------------'

mvn -v


